// yingpingfankui.entity.ts
import { Yingshishipin } from 'src/admin/yingshishipin/entities/yingshishipin.entity';
import { EntityBasis } from 'src/common/database/EntityBasis';
import { UserEntity } from 'src/user/entities/user.entity';
import {
  Entity,
  Column,
  PrimaryGeneratedColumn,
  ManyToOne,
  JoinColumn,
} from 'typeorm';

@Entity('yingpingfankui')
export class Yingpingfankui extends EntityBasis {
  @PrimaryGeneratedColumn()
  id: number;

  @Column({
    type: 'enum',
    enum: [1, 2, 3, 4, 5],
    comment: '评分（1-5分）',
  })
  pingfen: number;

  @Column({
    type: 'text',
    nullable: true,
    comment: '评语',
  })
  pingyu: string;

  // 多对一关系：多个反馈对应一个用户
  @ManyToOne(() => UserEntity, (user) => user.feedbacks)
  @JoinColumn({ name: 'user_id' }) // 指定外键列名
  user: UserEntity;

  // 多对一关系：多个反馈对应一个影视视频
  @ManyToOne(() => Yingshishipin, (shipin) => shipin.feedbacks)
  @JoinColumn({ name: 'shipin_id' }) // 指定外键列名
  shipin: Yingshishipin;
}
